<?php

use yii\db\Migration;

/**
 * Class m190313_074804_wx_qrcode
 */
class m190313_074804_wx_qrcode extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        $this->createTable('wx_qrcode', [
            'id'             => $this->primaryKey()->notNull()->unsigned()->comment('卡券二维码主键id'),
            'qrcode_name'    => $this->string(32)->notNull()->defaultValue('')->comment('卡券二维码名称，比如：团购券二维码'),
            'card_id'        => $this->string(64)->notNull()->defaultValue('')->comment('卡券card_id'),
            'expire_seconds' => $this->bigInteger(10)->unsigned()->comment('二维码的有效时间,60-1800s，不填默认一年'),
            'openid'         => $this->string(32)->defaultValue('')->comment('指定领取者的openid，只有该用户能领取'),
            'is_unique_code' => $this->tinyInteger(1)->defaultValue(0)->comment('指定下发二维码，生成的二维码随机分配一个code,默认false'),
            'outer_id'       => $this->tinyInteger(1)->defaultValue(0)->comment('领取场景值，用于领取渠道的数据统计，默认值为0'),
            'outer_str'      => $this->string(128)->defaultValue('')->comment('outer_id字段升级版本，字符串类型')
        ], $tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m190313_074804_wx_qrcode cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190313_074804_wx_qrcode cannot be reverted.\n";

        return false;
    }
    */
}
